package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.model.wemedia.pojos.WmMaterial;
import com.heima.wemedia.service.WmChannelService;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {
    @Autowired
    private WmMaterialService wmMaterialService;

    /**
     * 图片上传
     * @param multipartFile
     * @return
     */
    @PostMapping("/upload_picture")
    public ResponseResult multipartfileController(MultipartFile multipartFile){
        ResponseResult responseResult = wmMaterialService.uploadPicture(multipartFile);
        return responseResult;
    }
    /**
     * 素材列表查询
     */
    @PostMapping("/list")
    public ResponseResult wmMaterialListController(@RequestBody WmMaterialDto wmMaterialDto){
            return wmMaterialService.findList(wmMaterialDto);
    }
    /**
     * 图片删除
     */
    @GetMapping("/del_picture/{id}")
    public ResponseResult deletePicture(@PathVariable("id")Integer id){
        ResponseResult responseResult = wmMaterialService.deleteById(id);
        return responseResult;
    }
    /**
     * 收藏
     */
    @GetMapping("/collect/{id}")
    public ResponseResult collectById(@PathVariable("id")Integer id){
        return  wmMaterialService.collectById(id);
    }
    /**
     * 取消收藏
     */
    @GetMapping("/cancel_collect/{id}")
    public ResponseResult collectById1(@PathVariable("id")Integer id){
        return  wmMaterialService.collectById1(id);
    }
}
